package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisManageGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 15:58:35
 */
@Repository
public class AnalysisManageGroupDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisManageGroupDao.class);

    public AnalysisManageGroup insert(final AnalysisManageGroup analysisManageGroup) {
        insert("AnalysisManageGroup.insert", analysisManageGroup);
        return analysisManageGroup;
    }

    public Boolean updateInfoById(final AnalysisManageGroup analysisManageGroup) {
        return update("AnalysisManageGroup.updateInfoById", analysisManageGroup) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisManageGroup.updateInfoByQuery", query) > 0;
    }

    public AnalysisManageGroup selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("AnalysisManageGroup.selectById", query);
    }

    public List<AnalysisManageGroup> selectByQuery(final Query query) {
        return queryForList("AnalysisManageGroup.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisManageGroup.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        AnalysisManageGroup analysisManageGroup = new AnalysisManageGroup();
        analysisManageGroup.setDeleteFlag(1);
        analysisManageGroup.setId(id);
        analysisManageGroup.setEntId(entId);

        return update("AnalysisManageGroup.updateInfoById", analysisManageGroup) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisManageGroup.deleteById", query) > 0;
    }
}